/-app ...
TopLayout.ts
main.css
start.ts
/-docs
/-docs/types
DocHost.ts
/-files
FileTree.css
FileTree.ts
/-imports
/-persistence
Drive.ts
indexedDB.ts
mountDrive.ts
/-typings
errors.js
functions.ts
index.html
try.js
x
      if (key.length > ignoreSuffix.length && key.slice(key.length - ignoreSuffix.length) === ignoreSuffix)
1
module teapo.app {
2
  
3
  export class TopLayout {
4
​
5
    private _drive: persistence.Drive = null;
6
    private _fileTree: teapo.files.FileTree = null;
7
    private _host: docs.DocHost = null;
8
    
9
    private _hostElement: HTMLElement = null;
10
    
11
    constructor() {
12
    }
13
  
14
    // TODO: extract add/remove handling in a separate place
15
    addClick() {
16
      var newFile = prompt('Create file:', this._fileTree.selectedFile() || '/' );
17
      if (!newFile)
18
        return;
19
      
20
      if (this._drive.read(newFile) === null) {
21
        this._drive.write(newFile, '');
22
      }
23
​
24
      // TODO select programmatically
25
      //this._fileTree.selectedFile(newFile);
26
    }
27
  
28
    deleteClick() { 
29
    }
30
  
31
  
32
    initWithMainContent(mainContent: HTMLElement) {
33
      this._hostElement = mainContent;
34
      if (this._hostElement && this._fileTree)
35
        this._hostAndTreeLoaded();
36
    }
37
  
38
    initWithTree(treeHost: HTMLElement) {
39
      try {
40
        var fileTree = new teapo.files.FileTree(treeHost);
41
​
42
        var uniqueKey = this._getUniqueKey();
43
        var domTimestamp = 0;
44
​
45
        persistence.mountDrive(
46
          fileTree,
47
          uniqueKey,
48
          domTimestamp,
49
          <any>teapo.persistence,
50
          mountedDrive => { 
51
            this._fileTree = fileTree;
52
            this._drive = mountedDrive;
53
            if (this._hostElement && this._fileTree)
54
              this._hostAndTreeLoaded();
55
          });
56
      }
57
      catch (error) {
20:39